package oc.tm.sg.admin.web.ctrl;

import oc.tm.sg.admin.web.service.ApplicationsService;
import oc.tm.sg.admin.web.service.ServicesService;

import org.smart4j.framework.ioc.annotation.Inject;
import org.smart4j.framework.mvc.DataContext;
import org.smart4j.framework.mvc.annotation.Action;
import org.smart4j.framework.mvc.annotation.Request;
import org.smart4j.framework.mvc.bean.Params;
import org.smart4j.framework.mvc.bean.Result;
import org.smart4j.framework.mvc.bean.View;

@Action
public class WebCtrl {
	
	@Inject
    private ApplicationsService applicationsService;
	@Inject
    private ServicesService servicesService;
	
	@Request.Get("/login")
    public View login() {
        return new View("login.jsp");
    }

    @Request.Post("/login")
    public View loginSubmit(Params params) {
        return new View("/welcome");
    }

    @Request.Get("/welcome")
    public View welcome() {
        return new View("welcome.jsp");
    }

    @Request.Get("/logout")
    public Result logout() {
        DataContext.Session.removeAll();
        return new Result(true);
    }
    
    
    @Request.Get("/chart")
    public View chart() {
        return new View("chart.jsp");
    }
    
    @Request.Get("/application")
    public View application(Params params) {
    	DataContext.Request.put("applicationList", applicationsService.getApplications());
        return new View("application.jsp");
    }
    
    @Request.Get("/service")
    public View service(Params params) {
    	DataContext.Request.put("serviceList", servicesService.getServices());
        return new View("service.jsp");
    }
    
    @Request.Get("/provider")
    public View provider(Params params) {
    	DataContext.Request.put("providerList", servicesService.getServices());
        return new View("provider.jsp");
    }
    
    @Request.Get("/consumer")
    public View consumer(Params params) {
        return new View("consumer.jsp");
    }
}
